let {links} =require('../model/index');

function Common(){

}

Common.prototype.loadStatic=function(ctx){
    let {staticJson,body}=ctx.state.scope;
    links.forEach((item,index)=>{
        if(item.url==ctx.url){
          item.selected=true;
        }
    });
    body.data=Object.assign(body.data,{links});
    let urls = ctx.url.split(/\//);
    let lastUrl = urls[urls.length - 1];
    if (!lastUrl) {
        lastUrl = 'index';
    }
    body.pageCss = staticJson[lastUrl].css;
    body.pageJs = staticJson[lastUrl].js;
    body.commonCss = staticJson.common.css;
    body.commonJs = staticJson.common.js;
}

let common=new Common();

module.exports=common;